package com.octopus.samples.douban;

import com.octopus.core.Octopus.Builder;
import com.octopus.core.matcher.ParserMatcher;
import com.octopus.core.matcher.RegexMatcher;
import com.octopus.core.parser.DispatcherParser;
import java.util.concurrent.TimeUnit;

/**
 * 爬取豆瓣电影分类
 *
 * @author shoulai.yang@gmail.com
 * @date 2019/08/02
 */
public class Main {

  public static void main(String[] args) {
    new Builder()
        .threads(2)
        .rateLimit(2, TimeUnit.SECONDS)
        .parser(
            new DispatcherParser(
                new ParserMatcher(new RegexMatcher(".*/j/search_tags.*"), new TagsParser()),
                new ParserMatcher(
                    new RegexMatcher(".*/j/search_subjects.*"), new SubjectsParser())))
        .autoStop()
        .build()
        .start("https://movie.douban.com/j/search_tags?type=movie");
  }
}
